#!/usr/bin/env bash

set -e -u

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

API_UMBRELLA_SRC_ROOT="$(dirname "$(dirname "$dir")" )"
export API_UMBRELLA_SRC_ROOT
export API_UMBRELLA_RUNTIME_CONFIG="/tmp/api-umbrella-mongodb-to-postgres-runtime_config.yml"

api-umbrella-exec resty --http-include "$dir/migrate.conf" "$dir/migrate.lua" "$@"

rm -f "$API_UMBRELLA_RUNTIME_CONFIG"
